package com.ruoyi.mall.service;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.mall.domain.MallOrder;
import com.ruoyi.mall.mapper.MallOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 订单Service业务层处理
 *
 * @author ruoyi
 * @date 2024-01-11
 */
@Service
public class MallOrderService {
    @Autowired
    private MallOrderMapper mallOrderMapper;

    /**
     * 查询订单
     *
     * @param orderId 订单主键
     * @return 订单
     */
    public MallOrder selectMallOrderByOrderId(Long orderId) {
        return mallOrderMapper.selectMallOrderByOrderId(orderId);
    }

    /**
     * 查询订单列表
     *
     * @param mallOrder 订单
     * @return 订单
     */
    public List<MallOrder> selectMallOrderList(MallOrder mallOrder) {
        return mallOrderMapper.selectMallOrderList(mallOrder);
    }

    /**
     * 新增订单
     *
     * @param mallOrder 订单
     * @return 结果
     */
    public int insertMallOrder(MallOrder mallOrder) {
        mallOrder.setCreateTime(DateUtils.getNowDate());
        return mallOrderMapper.insertMallOrder(mallOrder);
    }

    /**
     * 修改订单
     *
     * @param mallOrder 订单
     * @return 结果
     */
    public int updateMallOrder(MallOrder mallOrder) {
        mallOrder.setUpdateTime(DateUtils.getNowDate());
        return mallOrderMapper.updateMallOrder(mallOrder);
    }

    /**
     * 批量删除订单
     *
     * @param orderIds 需要删除的订单主键
     * @return 结果
     */
    public int deleteMallOrderByOrderIds(Long[] orderIds) {
        return mallOrderMapper.deleteMallOrderByOrderIds(orderIds);
    }

    /**
     * 删除订单信息
     *
     * @param orderId 订单主键
     * @return 结果
     */
    public int deleteMallOrderByOrderId(Long orderId) {
        return mallOrderMapper.deleteMallOrderByOrderId(orderId);
    }
}
